<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="css/a.css">
    <link rel="stylesheet" href="css/styles.css">
    <script src="js/jquery-3.4.1.min.js"></script>
    <script>
        function dolog() {
            var username = $("#username");
            var password = $("#password");
            var role = $("#role");
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "loginCheckServlet",//url
                data: $('#logform1').serialize(),
                success: function (data) {
                    data = JSON.parse(data);//解析去转义字符
                    alert(data.msg);
                    if(data.flag=="1"){
                        location.href="AdminD.jsp";
                    }else if (data.flag=="2"){
                        location.href="Doctor.jsp";
                    }else if (data.flag=="3"){
                        location.href="家属页面.jsp";
                    }else if (data.flag=="4"){
                        location.href="游客页面.jsp";
                    }
                },
                error: function () {
                    alert("异常！");
                }
            });

        }
    </script>
    <script type="text/javascript">
        var i=0;
        setInterval('changeColor()',500);
        function changeColor(){
            var div=document.getElementById('character');
            var colorArr=['#8A2BE2','#DEB887','#7FFF00','#008B8B','#FF1493'];
            if(i==colorArr.length){
                i=0;
            }else{
                div.style.color=colorArr[i++%colorArr.length];
            }
        }
    </script>
</head>
<body>
<header><h1 id="character">欢迎使用!医务管理系统</h1></header>
    <aside class="login-box" style="float: right;margin-right: 0;width: 600px;left: 70%">
        <h2>查询服务</h2>
        <form id="logform1">

            <div class="user-box" style="line-height:39.4px ;height: 43.4px;">
                <input type="username" style="height: 33px;" required="required" autofocus="autofocus" name="username" id="username">
                <br>
                <label>用户名</label>
            </div>
            <div class="user-box"  style="line-height:39.4px ;height: 43.4px;">
                <input type="username" style="height: 33px;" required="required" autofocus="autofocus" name="password" id="password">
                <label>密&nbsp;&nbsp;码：</label>
            </div>
            <input hidden type="text" id="role" name="role" value="family">
            <a onclick="dolog()" href="#logform1" style="width: 40px;height: 20.8px;line-height: 20.8px;">
                <span></span>
                <span></span>
                <span></span>
                <span></span>
                登入</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="注册窗口.jsp" style="width: 40px;height: 20.8px;line-height: 20.8px;">
                <span></span>
                <span></span>
                <span></span>
                <span></span>注册</a>
        </form>

    </aside>

<!--<footer>Copyright &copy; 2020</footer>-->
</body>
</html>